Skip to content

fix: do not treat a void value_type as a container in copy/move traits - #6327

Open
henryiii wants to merge 1 commit into
pybind:masterfrom
henryiii:fix/void-value-type-traits
Open

henryiii wants to merge 1 commit into
pybind:masterfrom
henryiii:fix/void-value-type-traits

Conversation

@henryiii

Copy link
Copy Markdown
Collaborator

🤖 AI text below 🤖

Description

Fixes #5983.

pybind11::detail::is_move_constructible, is_copy_constructible and is_copy_assignable recurse into T::value_type to check container elements. A type with typedef void value_type (for example CGAL::SM_Halfedge_index before CGAL 6.2) is not a container, but the traits recursed into void and returned false. The result was a RuntimeError ("neither movable nor copyable") when a function returned the type by value, and a static_assert failure with py::init(factory).

container_value_type_traits now ignores a void value_type. The result for real containers does not change.

The test is a set of static_asserts in tests/test_copy_move.cpp. They fail without the fix.

Suggested changelog entry:

  • Fixed pybind11::detail::is_move_constructible, is_copy_constructible and is_copy_assignable returning false for types with a void value_type.

A type with `typedef void value_type` made is_move_constructible,
is_copy_constructible and is_copy_assignable false, because the traits
recursed into `void`.

Fixes pybind#5983

Assisted-by: ClaudeCode:claude-fable-5-2
@henryiii
henryiii marked this pull request as ready for review November 29, 2026 03:42

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG]: std::move_constructible and pybind11::detail::is_move_constructible differ

1 participant